namespace FutureApp.Migrations
{
    using System;
    using System.Collections.Generic;
    using System.Data.Entity.Infrastructure.Annotations;
    using System.Data.Entity.Migrations;
    
    public partial class _20161208Orders : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.FutureOrderHead",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        GoodName = c.String(nullable: false, maxLength: 50),
                        GoodPrice = c.Double(nullable: false),
                        Nums = c.Int(nullable: false),
                        SellName = c.String(nullable: false, maxLength: 50),
                        SellIdentity = c.String(nullable: false, maxLength: 15),
                        HomeAddress = c.String(nullable: false, maxLength: 50),
                        Company = c.String(nullable: false, maxLength: 50),
                        CompanyAddress = c.String(nullable: false, maxLength: 50),
                        SellTelephone = c.String(nullable: false, maxLength: 11),
                        SellCard = c.String(nullable: false, maxLength: 50),
                        IsActive = c.Boolean(nullable: false),
                        IsDeleted = c.Boolean(nullable: false),
                        DeleterUserId = c.Long(),
                        DeletionTime = c.DateTime(),
                        LastModificationTime = c.DateTime(),
                        LastModifierUserId = c.Long(),
                        CreationTime = c.DateTime(nullable: false),
                        CreatorUserId = c.Long(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_OrderHead_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.FutureUsers", t => t.CreatorUserId)
                .ForeignKey("dbo.FutureUsers", t => t.DeleterUserId)
                .ForeignKey("dbo.FutureUsers", t => t.LastModifierUserId)
                .Index(t => t.DeleterUserId)
                .Index(t => t.LastModifierUserId)
                .Index(t => t.CreatorUserId);
            
            CreateTable(
                "dbo.FutureOrderMain",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        Num = c.String(maxLength: 50),
                        MainPrice = c.Double(nullable: false),
                        MainDate = c.DateTime(nullable: false),
                        IsActive = c.Boolean(nullable: false),
                        HeadId = c.Guid(nullable: false),
                        IsDeleted = c.Boolean(nullable: false),
                        DeleterUserId = c.Long(),
                        DeletionTime = c.DateTime(),
                        LastModificationTime = c.DateTime(),
                        LastModifierUserId = c.Long(),
                        CreationTime = c.DateTime(nullable: false),
                        CreatorUserId = c.Long(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_OrderMain_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.FutureUsers", t => t.CreatorUserId)
                .ForeignKey("dbo.FutureUsers", t => t.DeleterUserId)
                .ForeignKey("dbo.FutureUsers", t => t.LastModifierUserId)
                .ForeignKey("dbo.FutureOrderHead", t => t.HeadId)
                .Index(t => t.HeadId)
                .Index(t => t.DeleterUserId)
                .Index(t => t.LastModifierUserId)
                .Index(t => t.CreatorUserId);
            
            CreateTable(
                "dbo.FutureStage",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        Num = c.Int(),
                        BeginPrice = c.Double(nullable: false),
                        EndPrice = c.Double(nullable: false),
                        AddPrice = c.Double(nullable: false),
                        IsActive = c.Boolean(nullable: false),
                        IsDeleted = c.Boolean(nullable: false),
                        DeleterUserId = c.Long(),
                        DeletionTime = c.DateTime(),
                        LastModificationTime = c.DateTime(),
                        LastModifierUserId = c.Long(),
                        CreationTime = c.DateTime(nullable: false),
                        CreatorUserId = c.Long(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_Stage_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.FutureUsers", t => t.CreatorUserId)
                .ForeignKey("dbo.FutureUsers", t => t.DeleterUserId)
                .ForeignKey("dbo.FutureUsers", t => t.LastModifierUserId)
                .Index(t => t.DeleterUserId)
                .Index(t => t.LastModifierUserId)
                .Index(t => t.CreatorUserId);
            
            AddColumn("dbo.FutureUsers", "IdentityCard", c => c.String(maxLength: 15));
            AddColumn("dbo.FutureUsers", "Telephone", c => c.String(maxLength: 11));
            AddColumn("dbo.FutureUsers", "ShopName", c => c.String(maxLength: 30));
            AddColumn("dbo.FutureUsers", "ShopId", c => c.String(maxLength: 30));
            AddColumn("dbo.FutureUsers", "ShopPassword", c => c.String(maxLength: 50));
            AddColumn("dbo.FutureUsers", "ShopItem", c => c.String(maxLength: 30));
            AddColumn("dbo.FutureUsers", "ShopCard", c => c.String(maxLength: 60));
            AddColumn("dbo.FutureUsers", "Address", c => c.String(maxLength: 60));
            AddColumn("dbo.FutureUsers", "UserType", c => c.Int());
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.FutureStage", "LastModifierUserId", "dbo.FutureUsers");
            DropForeignKey("dbo.FutureStage", "DeleterUserId", "dbo.FutureUsers");
            DropForeignKey("dbo.FutureStage", "CreatorUserId", "dbo.FutureUsers");
            DropForeignKey("dbo.FutureOrderMain", "HeadId", "dbo.FutureOrderHead");
            DropForeignKey("dbo.FutureOrderMain", "LastModifierUserId", "dbo.FutureUsers");
            DropForeignKey("dbo.FutureOrderMain", "DeleterUserId", "dbo.FutureUsers");
            DropForeignKey("dbo.FutureOrderMain", "CreatorUserId", "dbo.FutureUsers");
            DropForeignKey("dbo.FutureOrderHead", "LastModifierUserId", "dbo.FutureUsers");
            DropForeignKey("dbo.FutureOrderHead", "DeleterUserId", "dbo.FutureUsers");
            DropForeignKey("dbo.FutureOrderHead", "CreatorUserId", "dbo.FutureUsers");
            DropIndex("dbo.FutureStage", new[] { "CreatorUserId" });
            DropIndex("dbo.FutureStage", new[] { "LastModifierUserId" });
            DropIndex("dbo.FutureStage", new[] { "DeleterUserId" });
            DropIndex("dbo.FutureOrderMain", new[] { "CreatorUserId" });
            DropIndex("dbo.FutureOrderMain", new[] { "LastModifierUserId" });
            DropIndex("dbo.FutureOrderMain", new[] { "DeleterUserId" });
            DropIndex("dbo.FutureOrderMain", new[] { "HeadId" });
            DropIndex("dbo.FutureOrderHead", new[] { "CreatorUserId" });
            DropIndex("dbo.FutureOrderHead", new[] { "LastModifierUserId" });
            DropIndex("dbo.FutureOrderHead", new[] { "DeleterUserId" });
            DropColumn("dbo.FutureUsers", "UserType");
            DropColumn("dbo.FutureUsers", "Address");
            DropColumn("dbo.FutureUsers", "ShopCard");
            DropColumn("dbo.FutureUsers", "ShopItem");
            DropColumn("dbo.FutureUsers", "ShopPassword");
            DropColumn("dbo.FutureUsers", "ShopId");
            DropColumn("dbo.FutureUsers", "ShopName");
            DropColumn("dbo.FutureUsers", "Telephone");
            DropColumn("dbo.FutureUsers", "IdentityCard");
            DropTable("dbo.FutureStage",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_Stage_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
            DropTable("dbo.FutureOrderMain",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_OrderMain_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
            DropTable("dbo.FutureOrderHead",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_OrderHead_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
        }
    }
}
